<!DOCTYPE html>
<!--[if IE 8 ]> <html lang="en" class="ie8"> <![endif]-->
<!--[if IE 9 ]> <html lang="en" class="ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="en"> <!--<![endif]-->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>回退登记</title>

<link href="form/css/normalize.css" rel="stylesheet"/>
<link href="form/css/jquery-ui.css" rel="stylesheet"/>
<link href="form/css/jquery.idealforms.min.css" rel="stylesheet" media="screen"/>
 
	<link id="easyuiTheme" rel="stylesheet" type="text/css" href="../jquery-easyui-1.5.3/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="../jquery-easyui-1.5.3/themes/icon.css"/>
    
<style type="text/css">
body{font:normal 15px/1.5 Arial, Helvetica, Free Sans, sans-serif;color: #222;background:url(form/image/pattern.png);overflow-y:scroll;padding:10px 0 0 0;}
#my-form{width:1024px;margin:0 auto;border:1px solid #ccc;padding:3em;border-radius:3px;box-shadow:0 0 2px rgba(0,0,0,.2);}
#comments{width:350px;height:100px;}
</style>

   <script type="text/javascript">
	    var contextPath = function() {
	        return  "/" + location.pathname.split("/")[1];
	    }
	    
		function getValue(name){
			var str=window.location.search;
			if (str.indexOf(name)!=-1){
				var pos_start=str.indexOf(name)+name.length+1;
				var pos_end=str.indexOf("&",pos_start);
				if (pos_end==-1){
					return str.substring(pos_start);
				} else {
					return str.substring(pos_start,pos_end);
				}
			} else {
				return "";
			}
		}
		
		var  themeName = getValue("theme");
		if (themeName!=""){
		    var cssurl  = $('#easyuiTheme').attr('href');  
		    var href = cssurl.substring(0, cssurl.indexOf('themes')) + 'themes/' + themeName + '/easyui.css';  
		    $('#easyuiTheme').attr('href', href);  
		}

	</script>
</head>
<body>


<div class="row">

  <div class="eightcol last">

    <!-- Begin Form -->
	<label>【保单退回信息登记】</label>
    <form id="my-form">

		<div>
			<label>投保单号:</label>
			<input id="insure_no" name="insure_no" type="text" autofocus onkeyup="insureNoEnter()"/>
			<label>&nbsp;&nbsp;&nbsp;</label>
        	<button id="markinfo" type="button">提交</button>
        	<button id="reset" type="button">重置</button>
		</div>
		
		<div><hr/></div>   
		
		<table>
			<tr>
				<td>
					<div><label>投保单号:</label><input id="insure_no1" name="insure_no1" type="text" readonly/></div>
				</td>
				<td>
					<label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label>
				</td>
				<td>
					<div><label>当前状态:</label><input id="status_info" name="status_info" type="text" readonly/></div>
				</td>
			</tr>
			<tr>
				<td>
					<div><label>投保人:</label><input id="applicant" name="applicant" type="text" readonly/></div>
				</td>
				<td>
					<label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label>
				</td>
				<td>
					<div><label>手机号码:</label><input id="mobilephone" name="mobilephone" type="text" readonly/></div>
				</td>
			</tr>
			<tr>
				<td>
					<div><label>所属项目:</label><input id="project" name="project" type="text" readonly/></div>
				</td>
				<td>
					<label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label>
				</td>
				<td>
					<div><label>投保时间:</label><input id="insure_time" name="insure_time" type="text" readonly/></div>
				</td>
			</tr>
			<tr>
				<td colspan=3 >
					<div><label>收件地址:</label><textarea id="address" name="address" style="width:500px; height:80px" readonly></textarea></div>
				</td>	
			</tr>
			<tr>
				<td colspan=3 >
					<div><label>备注说明:</label><textarea id="remark" name="remark" style="width:500px; height:80px" readonly></textarea></div>
				</td>	
			</tr>
		</table>
    </form>

    <!-- End Form -->

  </div>

</div>


<script type="text/javascript" src="form/js/jquery-1.8.2.min.js"></script>
 
<script type="text/javascript" src="form/js/jquery-ui.min.js"></script>
<script type="text/javascript" src="form/js/jquery.idealforms.js"></script>


    <script type="text/javascript" src="../jquery-easyui-1.5.3/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="../jquery-easyui-1.5.3/locale/easyui-lang-zh_CN.js"></script>
    
<script type="text/javascript">
var options = {
	onFail: function(){
		alert( $myform.getInvalid().length +' invalid fields.' )
	},
	inputs: {
		'password': {
			filters: 'required pass',
		},
		'username': {
			filters: 'required username',
			data: {
			//ajax: { url:'validate.php' }
			}
		},
		'file': {
			filters: 'extension',
			data: { extension: ['jpg'] }
		},
		'comments': {
			filters: 'min max',
			data: { min: 50, max: 200 }
		}
	}	
};

var $myform = $('#my-form').idealforms(options).data('idealforms');

$myform.focusFirst();

$('#reset').click(function(){
	$myform.reset().fresh().focusFirst();
});

$('#markinfo').click(function(){
	commitInsureNo();
});

function insureNoEnter(){
	var code = event.keyCode;
	if(code == 13){
		commitInsureNo();
	}
}

function commitInsureNo(){
	$.ajax({
		type:'POST',
		url:contextPath()+'/mdmis/markReturn',
	    data:{insure_no:$('#insure_no').val()},
	    dataType:'json',
	    beforeSend: function () {
			$.messager.progress({ 
			       　title: '提示', 
				msg: '操作进行中，请稍候……', 
				text: '' 
			});
	    },
	    complete: function () {
			$.messager.progress('close');
	    },
	    success:function(result){
			if (result.warningTab) {
				$.messager.alert('警告！',result.warningMsg,'warning');
			}
			if (result.success){
				$('#insure_no').val('');
				$('#insure_no1').val(result.data.insure_no);
				$('#status_info').val(result.data.status_info);
				$('#applicant').val(result.data.applicant);
				$('#mobilephone').val(result.data.mobilephone);
				$('#project').val(result.data.project);
				$('#insure_time').val(result.data.insure_time);
				$('#address').val(result.data.address);
				$('#remark').val(result.data.remark);
			    $.messager.show({
			        title: 'Success',
			        msg: '操作完成！'
			    });
				$('#insure_no').focus();
			} else {
				if (result.errTab=='stop') {
					$.messager.alert('警告！',result.errMsg,'warning');
				}
				if (result.errMsg=='Data existed') {
					$.messager.alert('警告！','该保单已经回销！本次操作失败！','warning');
				}
			    $.messager.show({	// show error message
			        title: 'Error',
			        msg: result.errMsg
			    });
				$myform.reset().fresh().focusFirst();
				$('#insure_no1').val(result.errMsg);
				//$('#insure_no1').val('保单信息不存在');
			}
		}
	});
}	

//touch页面,记录用户进入页面
$.ajax({
	url : contextPath()+"/mdmis/touch",
	type : "get",
	data : {
		//"traceRandom":trace_random,
		//"recordID":trace_recordID,
		"target":location.pathname,
		"operation":"[进入页面]全单回退登记"
	},
	dataType : "json",	// 数据返回类型
    cache : false, 	// 是否缓存
    async : true   	// 默认为true 异步请求
});
</script>

</body>
</html>